package com.qtenv.datasync.base;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;

import java.util.Map;

/**
 * @ClassName BaseJobHandler
 * @Author CBL
 * @Date 2022/6/27 10:04
 **/
public class BaseJobHandler {
    private static final String SPILITER = ";";
    private static final String COMMENT = "#";
    private static final String COLON = ":";

    public Map<String, Object> getParamMap(String param) {
        Map<String, Object> paramMap = MapUtil.newHashMap();
        if (StrUtil.isNotBlank(param)) {
            String p = param.replaceAll("\r\n", "");
            for (String line : param.split(SPILITER)) {
                if (!line.startsWith(COMMENT)) {
                    String[] params = line.split(COLON);
                    paramMap.put(params[0], params[1]);
                }
            }
        }
        return paramMap;
    }
}
